<template>
  <!-- 经销商列表（全网下发经销商查询） -->
  <div>
    <FilterTable
      ref="table"
      height="450"
      :columns="columns"
      :isSelectColumn="false"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
      columnsRef="projectOperating_projram_commonForm_detail-dealer-all_01"
    >
    </FilterTable>
  </div>
</template>

<script>
// import dealerDialog from './dealerDialog'
import { dictionary } from '@/utils/dictMixin';
//经销商窗口
import dealerMadal from '@/pages/cms-common/dealerdata';
import { selectAllDealerPage } from '@/api/cms-api/projectOperating/program/distribution';
export default {
  mixins: [dictionary],
  components: {
    dealerMadal
  },
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      projectProgramId: '', //营销方案ID
      columns: this.creatHeader(),
      fetchParams: {}, //ipa 接口
      fetchApi: selectAllDealerPage // 全网下发经销商查询
    };
  },
  created(){
    if (this.value != null) {
      this.init();
    }
  },
  methods: {
    async init() {
      //营销方案ID
      this.projectProgramId = this.value.rowData.projectProgramId;
      this.fetchParams = {"projectProgramId":this.projectProgramId};
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        { title: '经销商代码', dataIndex: 'dealerCode', sorter: true },
        { title: '经销商简称', dataIndex: 'dealerShortname', sorter: true },
        { title: '经销商全称', dataIndex: 'dealerName', sorter: true },
        { title: '是否查看', dataIndex: 'isView', sorter: true ,
          render: props => {    //编码转汉字
            let isView = props.row.isView;
            if(isView==null || typeof(isView)=='undefined' || isView=='')
                isView = 10041002;
            return <span>{this.createDictText(isView, '1004')}</span>;
          }},
        { title: '首次查看人', dataIndex: 'firstViewPersonName', sorter: true },
        { title: '首次查看时间', dataIndex: 'firstViewTime', sorter: true ,dateFormat:'yyyy-MM-dd'}
        
      ];
    }
  }
};
</script>
